package jp.co.redfox.archclub.utility.datas;

import jp.co.redfox.archclub.poker.GameFile;
import jp.co.redfox.archclub.poker.player.Abator;
import jp.co.redfox.archclub.poker.player.UserPlayer;

public class UserPlayerData extends AbstractFixedLengthData {

    private static final UserPlayerData singleton = new UserPlayerData();
    private static final String FILE_PATH = "user.dat";

    private UserPlayerData() {
        super(5, new int[] { 40, 5, 11 });
    }

    public static UserPlayerData getInstance() {
        return singleton;
    }

    public UserPlayer load(String id) {
        super.loadFixedLengthData(id);

        if(dataContents[0] == null)
            return null;
        
        UserPlayer ret = new UserPlayer(dataContents[0]);
        Abator abator = AbatorData.getInstance().load(dataContents[1]);
        ret.setAbator(abator);
        return ret;
    }

    public static void save(UserPlayer user) {

    }

    @Override
    protected GameFile getDataFile() {
        return new GameFile(FILE_PATH);
    }
}
